package com.shopx.config.controller;

import com.shopx.base.anno.RepearSubmitChkAnno;
import com.shopx.base.controller.BaseController;
import com.shopx.base.dto.Result;
import com.shopx.base.exception.ShopxException;
import com.shopx.base.utils.ResultUtil;
import com.shopx.cmm.DTO.PageDTO;
import com.shopx.config.bean.SysHolidays;
import com.shopx.config.model.SysHolidaysModel;
import com.shopx.config.service.ISysHolidaysService;
import com.shopx.core.common.CommonConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * TODO
 *
 * @author lituo
 * @className: SysHolidaysController
 * @date 2024-08-13
 */
@RestController
@Slf4j
@RequestMapping(value = "/sysHolidays")
public class SysHolidaysController extends BaseController {

    @Resource
    private ISysHolidaysService sysHolidaysService;

    @PostMapping(value = "/queryPageList")
    public Result<PageDTO> queryPageList(@RequestBody SysHolidaysModel sysHolidays) throws ShopxException {
        PageDTO<SysHolidaysModel> pageDTO = sysHolidaysService.getListPage(sysHolidays);
        return ResultUtil.ok(pageDTO);
    }

    @PostMapping(value = "/insertOne")
    @RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)
    public Result<Integer> insertOne(@RequestBody SysHolidays sysHolidays) throws ShopxException {
        int result = sysHolidaysService.insertSelective(sysHolidays);
        return ResultUtil.ok(result);
    }

    @PostMapping(value = "/updateOne")
    @RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)
    public Result<Integer> updateOne(@RequestBody SysHolidays sysHolidays) throws ShopxException {
        int result = sysHolidaysService.updateByPrimaryKeySelective(sysHolidays);
        return ResultUtil.ok(result);
    }

    @PostMapping(value = "/queryOneByPrimaryKey")
    public Result<SysHolidaysModel> queryOneByPrimaryKey(@RequestBody SysHolidays sysHolidays) throws ShopxException {
        SysHolidaysModel result = sysHolidaysService.selectByPrimaryKey(sysHolidays);
        return ResultUtil.ok(result);
    }
	
	@PostMapping(value = "/deleteChecked")
	@RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)
					public Result<Integer> deleteChecked(@RequestBody SysHolidays sysHolidays) throws ShopxException {
		int result = sysHolidaysService.deleteByPrimaryKey(sysHolidays);
		return ResultUtil.ok(result);
	}
}

